package test1;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
import java.util.Arrays;

public class test {
    public static void main(String[] args) throws IOException {
        File file = new File("D:\\1.text");
//        FileInputStream input = new FileInputStream(file);
//        int a;
//        while ((a = input.read()) != -1)
//            System.out.print((char) a);
//        input.close();
        FileOutputStream output=new FileOutputStream(file,false);
        int b;
        output.write("李文骥".getBytes("GBK"));
        System.out.println(Arrays.toString("李文骥".getBytes("GBK")));
        System.out.println(Arrays.toString("李文骥".getBytes(StandardCharsets.UTF_8)));
        FileInputStream input = new FileInputStream(file);
        int a;
        byte[] bytes=new byte[2];
        String str;
        while ((a= input.read(bytes)) != -1) {
            for (byte i:bytes) {
                System.out.println(i);
            }
           str = new String(bytes,"GBK");
          System.out.print(str);System.out.print("\n");
        }
        output.close();
        input.close();

    }
    }
